<template>
  <div class="hello"> 
      <h2>{{msg}}</h2>
    <input placeholder="输入框" /> 
  </div>
</template>

<script>
export default {
  name: "vuex",
  data() {
    return {
      sde: "传到子组件",
      msg:'',
      count: 0
    };
  },
  created: function() {
 
  },
  activated: function() {
      console.log('1')
  },
  deactivated() {
      console.log('2')      
  },
  methods: {
    increment() {
      this.count++;
    },
    pro() {
      Mother.prototype.lastName = "lin";
      function Mother() {}
      function Son() {}
      function inherit(targ, ori) {
        targ.prototype = ori.prototype;
      }

      let son = new Son();

      inherit(Son, Mother); //Son 和 Mother 指向同个索引地址，修改了Son的原型会导致Mother的原型也改变
      console.log(son.lastName); //undefined

      let son1 = new Son();
      console.log(son1.lastName); //lin

      Son.prototype.sex = "male";
      let mom = new Mother();
      console.log(mom.sex); //male

      // 圣杯模式
      function Binherit(targ, ori) {
        function B() {} //定义空白的函数，闭包私有化
        B.prototype = ori.prototype; //让空白函数的原型 = 父级的原型 ,
        targ.prototype = new B(); //子级的原型 = new 空白函数
        targ.prototype.constuctor = targ; //修正构造函数
        targ.prototype.uber = ori.prototype; //超类，查找原型
      }
      Binherit(Son, Mother);
      Son.prototype.sex = "female";
      console.log(mom.sex); //male
    }
  }
};
</script>

<style scoped>
h1,
h2 {
  font-weight: normal;
}
</style>
